package com.gopay.common.logging;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

public final class LogsCollector {

	private static LogsCollector instance = new LogsCollector();

	private List<String> logs = new ArrayList<String>();

	private LogsCollector() {

	}

	public static LogsCollector getInstance() {
		return instance;
	}

	public void collect(String log) {
		logs.add(log);
	}

	public List<String> getAndClear() {
		List<String> removes = new ArrayList<String>();

		for (Iterator<String> i = logs.iterator(); i.hasNext();) {
			removes.add(i.next());
		}

		logs.removeAll(removes);
		return removes;
	}
	
	public void clearAll() {
		logs.clear();
	}
}
